/*
 ============================================================================
 Name        : test_rio.c
 Author      : 11
 Version     :
 Copyright   : Your copyright notice
 Description : Hello World in C, Ansi-style
 ============================================================================
 */

#define _GNU_SOURCE
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <unistd.h>
#include <semaphore.h>
#include <error.h>
#include <malloc.h>
#include <netdb.h>
#include <netinet/in.h>
#include <assert.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdint.h>
#include <string.h>
#include <time.h>
#include <unistd.h>

#include <sys/stat.h>
#include <sys/types.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
#include <sys/mman.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <arpa/inet.h>

#include "riocpplib.h"


int main(void) {
	int ret=0;
	int i=0;
	unsigned int SRIO_ID;
	unsigned int *pSrc;
	char buf[2048];

	ret=bslRioPortInit(1);
	if(ret==0)
	{
		printf("INIT SRIO PORT DONE\n");
	}
	else
	{
		printf("INIT SRIO PORT FAILED\n");
		return -1;
	}

	SRIO_ID=bslRioGetID();
	printf("SRIO ID is 0x%x\n",SRIO_ID);

	for(i=0;i<2048;i++)
	{
		buf[i]=i+1;
	}

	ret=bslRioSendData(0x8, 0x2000000, buf,256);
	if(ret<0)
	{
		printf("SEND SRIO DATA FAILED\n");
		return -1;
	}
	else
	{
		printf("SEND SRIO DATA DONE\n");
	}



	ret=bslRioSendDoorbell(0x8, 0x55aa);
	if(ret<0)
	{
		printf("SEND DOORBELL FAILED\n");
		return -1;
	}
	else
	{
		printf("SEND DOORBELL DONE\n");
	}


	return EXIT_SUCCESS;
}
